<script>

import Block from '../Block'

import { isObject } from '@/utils/kris_utils'


export default {
    components: {
        Block
    },
    props:{
        data:{
            type:Object,
            required:true,
            default(){
                return null
            }
        }
    },
    data() {
        return {
        }
    },
    methods:{
        isObject,
        toOperatorProfile(operator){
            this.$router.push({
                path: `/personnel-files/show/${operator.id}`,
                query: { tag_title: operator.name + '-查看', show: true }
            })
        }
    }
}
</script>

<template>
    <div class="field-modify-hisory">
        <Block :title="data.title">
            <el-table :data="data.fields" stripe style="width: 100%">
                <el-table-column prop="fieldCfg.label" label="字段" />

                <el-table-column prop="before" label="更改前">
                    <template slot-scope="scope">
                        <component v-if="scope.row.fieldCfg.component" :is="scope.row.fieldCfg.component" type="before" v-bind="scope.row" />
                        <span v-else>{{ scope.row.before }}</span>
                    </template>
                </el-table-column>
                <el-table-column prop="after" label="更改后">
                    <template slot-scope="scope">
                        <component v-if="scope.row.fieldCfg.component" :is="scope.row.fieldCfg.component" type="after" v-bind="scope.row" />
                        <span v-else>{{ scope.row.after }}</span>
                    </template>
                </el-table-column>

                <el-table-column prop="operator" label="操作人">
                    <template slot-scope="scope">
                        <el-button type="text" @click="toOperatorProfile(data.operator)">{{ data.operator.name }}</el-button>
                    </template>
                </el-table-column>
            </el-table>
        </Block>
    </div>
</template>

<style lang="scss">
.field-modify-hisory {
    margin-top: 24px;
    background-color: #fff;
    padding: 10px;
    border-radius: 10px;

    &:first-child {
        margin-top: 0;
    }

    .header {
        padding: 0;
    }
}
</style>